import 'package:flutter/material.dart';
import 'chat/chat_page.dart';
import 'discover/discover_page.dart';
import 'friends/friends_page.dart';
import 'mine/mine_page.dart';

class RootPage extends StatefulWidget {
  const RootPage({super.key});

  @override
  State<RootPage> createState() => _RootPageState();
}

class _RootPageState extends State<RootPage> {
  int _currentIndex = 0;

  final _pages = [
    const ChatPage(),
    const FriendsPage(),
    const DiscoverPage(),
    const MinePage(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _pages[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        fixedColor: Colors.green,
        type: BottomNavigationBarType.fixed,
        items: const [
          BottomNavigationBarItem(
            icon: Icon(Icons.message),
            label: '微信',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.bookmark),
            label: '通讯录',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.history),
            label: '发现',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.person_outline),
            label: '我',
          ),
        ],
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
      ),
    );
  }
}
